#ifndef MISC_HPP
#define MISC_HPP

#include<arduino.h>

void setPin(String cmd);

void flushReply(String newReply);
void print2Serial(const char* content);

void flushSerialInput();

long myParseInt(String intStrIn);

int myParsePin(String pinStrIn);

String int2Str(int val, int padLen);

String float2Str(float val, int digitNum);

String formatPinIdx(int pinIdx);

// seperated by ',', may end with a ','
void myParseInts(String intsStrIn, long** intsOut, int* intNum);

void parseIntTest(String val);
void printHelp();

bool searchPara(String cmd, String para);

bool searchPara(const char* cmd, const char* para);

void debug_parseInt(String strIn) ;

void debug_parseInts(String strIn);

inline bool StartWith(const char *a, const char *b)
{
  return (strncmp(a, b, strlen(b)) == 0);
}

inline int IndexOf(const char* a, const char b)
{
	const char* c = a;
	while (*c != '\0') {
		if (*c == b) {
			return c - a;
		}
	}
	return -1;
}

#endif